package com.app.xinfadi.widget.dialog;

import android.content.Context;
import android.graphics.Color;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.app.xinfadi.R;
import com.flyco.animation.Attention.Swing;
import com.flyco.dialog.utils.CornerUtils;
import com.flyco.dialog.widget.base.BaseDialog;

/*
审核
 */
public class ExamineAndVerifyDialog extends BaseDialog<ExamineAndVerifyDialog> {
    private EditText messageEdt;
    private Button sumbitBtn;
    private String buttonTitleLeft;
    private Button nosumbitBtn;
    public String buttonRight;

    public ExamineAndVerifyDialog(Context context) {
        super(context);
    }

    public ExamineAndVerifyDialog(Context context, String buttonTitleLeft, String buttonRight) {
        super(context);
        this.buttonTitleLeft = buttonTitleLeft;
        this.buttonRight = buttonRight;
    }

    @Override
    public View onCreateView() {
        widthScale(0.85f);
        showAnim(new Swing());
        // dismissAnim(this, new ZoomOutExit());
        View inflate = View.inflate(mContext, R.layout.examine_and_verify_dialog_layout, null);
        messageEdt = (EditText) inflate.findViewById(R.id.messageEdt);
        sumbitBtn = (Button) inflate.findViewById(R.id.sumbitBtn);
        nosumbitBtn = (Button) inflate.findViewById(R.id.nosumbitBtn);
        inflate.setBackgroundDrawable(
                CornerUtils.cornerDrawable(Color.parseColor("#ffffff"), dp2px(5)));


        return inflate;
    }

    @Override
    public void setUiBeforShow() {
        float radius = dp2px(5);
        int lvBgColor = Color.parseColor("#ddffffff");
        int itemPressColor = Color.parseColor("#ffcccccc");
//        nosumbitBtn.setBackgroundDrawable(CornerUtils.listItemSelector(radius, lvBgColor, itemPressColor, 1, 0));

        if (!TextUtils.isEmpty(buttonTitleLeft))
            nosumbitBtn.setText(buttonTitleLeft);
        if (!TextUtils.isEmpty(buttonRight))
            sumbitBtn.setText(buttonRight);
        sumbitBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (suggestionOnclickListener != null) {
                    suggestionOnclickListener.onClick(v, messageEdt.getText().toString().trim());
                }
                dismiss();
            }
        });
        nosumbitBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (noSuggestionOnclickListener != null) {
                    noSuggestionOnclickListener.onClick(v, messageEdt.getText().toString().trim());
                }
                dismiss();
            }
        });
    }

    public SuggestionOnclickListener noSuggestionOnclickListener;//通过
    public SuggestionOnclickListener suggestionOnclickListener;//不通过

    public void setSuggestionOnclickListener(SuggestionOnclickListener noSuggestionOnclickListener, SuggestionOnclickListener suggestionOnclickListener) {
        this.noSuggestionOnclickListener = noSuggestionOnclickListener;
        this.suggestionOnclickListener = suggestionOnclickListener;
    }

    public interface SuggestionOnclickListener {
        public void onClick(View v, String suggestion);
    }

}
